package com.gw.detail.controllor.detail;

import com.gw.detail.domain.Fzgas;
import com.gw.detail.service.IFzgasService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 主要安全措施Controller
 *
 * @author WangBin
 * @date 2021-04-30
 */
@RestController
@RequestMapping("/detail/fzgas")
public class FzgasController extends BaseController {
    @Autowired
    private IFzgasService fzgasService;

    /**
     * 查询主要安全措施列表
     */
    @PreAuthorize("@ss.hasPermi('detail:fzgas:list')")
    @GetMapping("/list")
    public TableDataInfo list(Fzgas fzgas) {
        startPage();
        List<Fzgas> list = fzgasService.selectFzgasList(fzgas);
        return getDataTable(list);
    }

    /**
     * 导出主要安全措施列表
     */
    @PreAuthorize("@ss.hasPermi('detail:fzgas:export')")
    @Log(title = "主要安全措施", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Fzgas fzgas) {
        List<Fzgas> list = fzgasService.selectFzgasList(fzgas);
        ExcelUtil<Fzgas> util = new ExcelUtil<Fzgas>(Fzgas.class);
        return util.exportExcel(list, "主要安全措施数据");
    }

    /**
     * 获取主要安全措施详细信息
     */
    @PreAuthorize("@ss.hasPermi('detail:fzgas:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(fzgasService.selectFzgasById(id));
    }

    /**
     * 新增主要安全措施
     */
    @PreAuthorize("@ss.hasPermi('detail:fzgas:add')")
    @Log(title = "主要安全措施", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Fzgas fzgas) {
        return toAjax(fzgasService.insertFzgas(fzgas));
    }

    /**
     * 修改主要安全措施
     */
    @PreAuthorize("@ss.hasPermi('detail:fzgas:edit')")
    @Log(title = "主要安全措施", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Fzgas fzgas) {
        return toAjax(fzgasService.updateFzgas(fzgas));
    }

    /**
     * 删除主要安全措施
     */
    @PreAuthorize("@ss.hasPermi('detail:fzgas:remove')")
    @Log(title = "主要安全措施", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(fzgasService.deleteFzgasByIds(ids));
    }
}
